<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;

Route::group('user', function () {
    // 注册
    Route::post('register', '\app\index\controller\UserController@register');
    //登录
    Route::post('login', '\app\user\controller\LoginController@login');
    // 找回密码/忘记密码
    Route::post('find_pwd', '\app\user\controller\UserController@findPassword');

    //需要登录
    Route::group(function () {
        // 退出登录
        Route::post('logout','\app\user\controller\LoginController@logout');
        // 修改密码
        Route::post('change_pwd', '\app\user\controller\UserController@changePassword');
        
        // 用户信息
        Route::post('user/get_info','\app\user\controller\UserController@getUserInfo');
        // 详情
        Route::post('user/detail','\app\user\controller\UserController@detail');
        // 修改用户信息
        Route::post('user/change_userinfo','\app\user\controller\UserController@changeUserInfo');

        // 猪厂申请
        // 新增
        Route::post('factory_apply/add','\app\user\controller\FactoryApplyController@add');
        // 列表
        Route::get('factory_apply/list','\app\user\controller\FactoryApplyController@list');

        // 猪厂
        // 详情
        Route::get('factory/detail','\app\user\controller\FactoryController@detail');
        // 猪厂选择列表
        Route::get('factory/select_list','\app\user\controller\UserFactoryController@selectList');
        // 选择猪厂
        Route::post('factory/select','\app\user\controller\UserFactoryController@selectFactory');

        // 异常分类
        // 下拉选择
        Route::get('abnormal_type/select_list','\app\user\controller\AbnormalTypeController@selectList');

    })->middleware(['check_user_login']);


    // 需要登录用户选择猪厂
    Route::group(function (){
        // 猪厂
        // 详情手机端数据展示补充
        Route::get('factory/detail_supply','\app\user\controller\FactoryController@detailSupply');
        // 统计
        Route::get('factory/statistic','\app\user\controller\FactoryController@statistic');
        
        // 猪栋
        // 列表
        Route::get('building/list','\app\user\controller\BarnController@list');
        // 详情
        Route::get('building/detail','\app\user\controller\BarnController@detail');
        // 栋 详情补充(手机端数据)
        Route::get('building/detail_supply','\app\user\controller\BarnController@detailSupply');
        // 下拉列表
        Route::get('building/select_list','\app\user\controller\BarnController@selectList');
        // 修改栋名
        Route::post('building/edit','\app\user\controller\BarnController@edit');

        // 猪栏
        // 列表
        Route::get('fence/list','\app\user\controller\FenceController@list');
        // 详情
        Route::get('fence/detail','\app\user\controller\FenceController@detail');
        // 下拉列表
        Route::get('fence/select_list','\app\user\controller\FenceController@selectList');
        //切换列表
        Route::get('fence/switch_list','\app\user\controller\FenceController@switchList');
        // 猪栏详情补充(手机端数据)
        Route::get('fence/detail_supply','\app\user\controller\FenceController@detailSupply');
//        // 今日食谱
//        Route::get('fence/today_cookbook','\app\user\controller\FenceEatPlanController@todayCookbook');
//        // 今日营养保健药品
//        Route::get('fence/today_nutrition','\app\user\controller\FenceNutritionPlanController@todayNutrition');
        // 出栏历史记录
        Route::get('out_fence/history','\app\user\controller\InOutBarnController@list');
//        // 修改栏名称
//        Route::post('fence/edit','\app\user\controller\FenceController@edit');

        // 猪
        // 列表
        Route::get('pig/list','\app\user\controller\PigController@list');
        // 详情
        Route::get('pig/detail','\app\user\controller\PigController@detail');
//        // 详情补充（手机端）
//        Route::get('pig/detail_supply','\app\user\controller\PigController@detailSupply');
//        // 疫苗记录
//        Route::get('pig/vaccinum_record','\app\user\controller\VaccinumRecordController@list');
//        // 治疗记录
//        Route::get('pig/treatment','\app\user\controller\TreatmentController@list');
//        // 今日食谱
//        Route::get('pig/today_cookbook','\app\user\controller\PigEatPlanController@todayCookbook');
        // 下拉列表
        Route::get('pig/select_list','\app\user\controller\PigController@selectList');
//        // 进出栏
//        Route::get('pig/in_out','\app\user\controller\PigController@inOut');

        // 疾病中心
        // 分类 下拉选择
        Route::get('disease_category/select_list','\app\user\controller\DiseaseCategoryController@selectList');
        // 列表
        Route::get('disease/list','\app\user\controller\DiseaseController@list');
        // 统计
        Route::get('disease/statistic','\app\user\controller\DiseaseController@statistic');

        // 异常中心
        // 列表
        Route::get('abnormal/list','\app\user\controller\AbnormalController@list');

        // 数据中心
        // 首页统计
        Route::get('index/statistic','\app\user\controller\IndexController@statistic');
        // 健康统计
        Route::get('pig_health/statistic','\app\user\controller\PigController@healthStatistic');
        // 猪栋/猪栏/猪 料肉比统计
        Route::get('feed_meat_ratio/statistic','\app\user\controller\FeedMeatRatioController@statistic');
        // 猪栋/猪栏/猪 料肉比比较
        Route::get('feed_meat_ratio/compare','\app\user\controller\FeedMeatRatioController@compare');
        // 生猪每日进食统计
        Route::get('pig_eat/daily_statistic','\app\user\controller\PigDailyEatController@statistic');
        // 生猪每日健康数据统计
        Route::get('pig_health/daily_statistic','\app\user\controller\PigHealthController@statistic');

        // 保健中心
        // 列表
        Route::get('health_fitness/list','\app\user\controller\HealthFitnessController@list');
        // 列表
        Route::get('health_fitness/statistic','\app\user\controller\HealthFitnessController@statistic');

        // 消毒中心
        // 列表
        Route::get('disinfect/list','\app\user\controller\DisinfectController@list');
        // 消毒事项 下拉选择
        Route::get('disinfect/select_list','\app\user\controller\DisinfectController@selectList');
        // 统计
        Route::get('disinfect/statistic','\app\user\controller\DisinfectController@statistic');

        // 食谱中心
        // 下拉选择列表
        Route::get('cookbook/select_list','\app\user\controller\CookBookController@selectList');
        // 计划饲料信息
        Route::get('cookbook/feed_info','\app\user\controller\CookBookController@feedInfo');
        // 使用食谱的猪栋列表
        Route::get('cookbook/barn_list','\app\user\controller\BarnController@useCookBookBarn');
        // 使用食谱的猪栏列表
        Route::get('cookbook/fence_list','\app\user\controller\FenceController@useCookBookFence');
        // 使用食谱的猪列表
        Route::get('cookbook/pig_list','\app\user\controller\PigController@useCookBookPig');

        // 疫苗记录
        // 列表
        Route::get('vaccines_record/list','\app\user\controller\VaccinesRecordController@list');

        // 上位机
        //绑定
        Route::post('machine/bind','\app\user\controller\MachineController@bind');
        //列表
        Route::get('machine/list','\app\user\controller\MachineController@list');
        //详情
        Route::get('machine/detail','\app\user\controller\MachineController@detail');
        //解绑
        Route::post('machine/unbind','\app\user\controller\MachineController@unbind');

    })->middleware(['check_user_login','check_user_factory']);

});

